<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>首页</title>
    <link rel="stylesheet" href="./bootstrap/bootstrap.min.css" />
  </head>
  <body>
    <button id="btn">弹出</button>

    <div
      id="liveToast"
      class="toast"
      role="alert"
      aria-live="assertive"
      aria-atomic="true"
    >
      登录成功
    </div>

    <script src="./bootstrap/bootstrap.min.js"></script>

    <script>
      // 给按钮加点击事件
      document.querySelector('#btn').onclick = function () {
        // 实例化轻提示对象
        const toast = new bootstrap.Toast(
          document.getElementById('liveToast'),
          {
            delay: 1500
          }
        )
        toast.show()
      }
    </script>
  </body>
</html>
